package com.mifengs.commonbase.net;

import com.mifengs.commonbase.Constant;

import retrofit2.CallAdapter;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by lihaoqi on 2018/8/16.
 */

public class NetRetorfit {

    private static CallAdapter.Factory rxJavaCallAdapterFactory = RxJavaCallAdapterFactory.create();
    private static Converter.Factory gsonConverterFactory = GsonConverterFactory.create();
    private static Retrofit retrofit;

    public static Retrofit getCommonRetrofit() {
        if (retrofit == null) {
            retrofit = new Retrofit.Builder()
                    .client(NetConfig.client)
                    .baseUrl(Constant.BaseUrl)
                    .addConverterFactory(gsonConverterFactory)
                    .addCallAdapterFactory(rxJavaCallAdapterFactory)
                    .build();
        }
        return retrofit;
    }

}

